<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
	<meta charset="utf-8" />
	<meta name="keywords" content="pinpin社保" />
	<meta name="description" content="pinpin社保" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="renderer" content="webkit" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>社保运营后台-代理员工</title>
	<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
	<!-- CSS to style the file input field as button and adjust the Bootstrap progress bars -->
	<link rel="stylesheet" href="/as/jquery-upload-file/css/jquery.fileupload.css">
	<link rel="stylesheet" href="/as/jquery-upload-file/css/jquery.fileupload-ui.css">
	<style type="text/css">
		.bar {
		    height: 18px;
		    background: green;
		}
	</style>
</head>
<body>
	<div id="wrapper">
		<%@ include file="/WEB-INF/jsp/common/menu.jsp" %>
        <div id="page-wrapper">
        	<div class="row">
                <div class="col-lg-12">
                    <!-- 路径导航 -->
                    <ol class="breadcrumb">
				      <li>社保后台</li>
                      <li>员工管理</li>
				      <li class="active"><fmt:formatNumber pattern="#" type="number" value="${(employeeQueryForm.month - (employeeQueryForm.month mod 100))/100 }"/>年${employeeQueryForm.month mod 100 }月</li>
				    </ol>
                </div>
            </div>
         	<div class="row" >
                <div class="col-lg-12">
                	<ol class="breadcrumb">
				      <li>增员城市提醒(${addWarnCities.size() }个)：</li>
				      <li onclick="toggleDiv('#addWarnCities')">点击查看</li>
				    </ol>
                    <ol class="breadcrumb" id="addWarnCities" style="display:none">
                  	 <c:forEach var="cityResult" items="${addWarnCities }">
                  	 <li>
                  	 	<label class="checkbox-inline" style="width:130px">${cityResult.city_name }(${cityResult.inc_date }号)</label>
                  	 </li>
                  	 </c:forEach> 
				    </ol>
                </div>
            </div>
        	<div class="row" >
                <div class="col-lg-12">
                <ol class="breadcrumb">
				      <li>减员城市提醒(${cutWarnCities.size() }个)：</li>
				      <li onclick="toggleDiv('#cutWarnCities')">点击查看</li>
				    </ol>
                    <ol class="breadcrumb" id="cutWarnCities" style="display:none">
                  	 <c:forEach var="cityResult" items="${cutWarnCities }">
                  	 <li>
                  	 	<label class="checkbox-inline" style="width:130px">${cityResult.city_name }(${cityResult.dec_date }号)</label>
                  	 </li>
                  	 </c:forEach> 
				    </ol>
                </div>
            </div>
        	<div class="row" >
                <div class="col-lg-12">
                    <ol class="breadcrumb">
				      <li>当月已增员城市(${addAlreadyCityList.size() }个)：</li>
                  	 <c:forEach var="cityResult" items="${addAlreadyCityList }">
                  	 <li>
                  	 	<c:choose>
                  	 	<c:when test="${0 == cityResult.inc_date }">
                  	 		<label class="checkbox-inline" style="width:130px;color:#093" onclick="javascript:$('#city_code').val(${cityResult.id });">
                  	 			${cityResult.name } (${cityResult.inc_date }号)</label>
                  	 	</c:when>
                  	 	<c:when test="${curr_date - 1 == cityResult.inc_date }">
                  	 		<label class="checkbox-inline" style="width:130px;color:#F90" onclick="javascript:$('#city_code').val(${cityResult.id });">
                  	 			${cityResult.name } (${cityResult.inc_date }号)</label>
                  	 	</c:when>
                  	 	<c:when test="${curr_date == cityResult.inc_date }">
                  	 		<label class="checkbox-inline" style="width:130px;color:#F93" onclick="javascript:$('#city_code').val(${cityResult.id });">
                  	 			${cityResult.name } (${cityResult.inc_date }号)</label>
                  	 	</c:when>
                  	 	<c:when test="${curr_date+1 == cityResult.inc_date }">
                  	 		<label class="checkbox-inline" style="width:130px;color:#F98" onclick="javascript:$('#city_code').val(${cityResult.id });">
                  	 			${cityResult.name } (${cityResult.inc_date }号)</label>
                  	 	</c:when>
                  	 	<c:otherwise>
                  	 		<label class="checkbox-inline" style="width:130px;" onclick="javascript:$('#city_code').val(${cityResult.id });">
                  	 			${cityResult.name } (${cityResult.inc_date }号)</label>
                  	 	</c:otherwise>
                  	 	</c:choose>
                  	 </li>
                  	 </c:forEach> 
				    </ol>
                </div>
            </div>
        	<div class="row" >
                <div class="col-lg-12">
                    <ol class="breadcrumb">
				      <li>当月已减员城市(${cutAlreadyCityList.size() }个)：</li>
                  	 <c:forEach var="cityResult" items="${cutAlreadyCityList }">
                  	 <li>
                  	 	<label class="checkbox-inline" style="width:130px">${cityResult.name }(${cityResult.dec_date }号)</label>
                  	 </li>
                  	 </c:forEach> 
				    </ol>
                </div>
            </div>
            <div class="row">
            	<div class="col-lg-12">
            		<div class="panel panel-default">
            			<div class="panel-body">
        			    	<div class="form-inline dt-bootstrap no-footer">
        			    		<!-- 表单查询 -->
        			    		<form action="" method="post" id="queryEmployeeForm" class="form-check">
        			    		<div class="row">
        			    			<div class="col-lg-12">
                                        <label class="checkbox-inline" style="padding-bottom:10px">
                                        	<input type="text" class="form-control" name="order_no" placeholder="请输入订单号" value="${employeeQueryForm.order_no }">
                                        </label>
                                        <label class="checkbox-inline" style="padding-bottom:10px">
                                        	<input type="text" class="form-control" name="id_card" placeholder="请输入身份证号码" value="${employeeQueryForm.id_card}">
                                        </label>
                                         <label class="checkbox-inline" style="padding-bottom:10px">
                                        <input type="text" class="form-control" name="month" id="month" value="${employeeQueryForm.month }" placeholder="选择月份" size="12" title="选择月份"
                                        	onClick="WdatePicker({dateFmt:'yyyyMM',minDate:'2015-10-01 00:00:00'})" onblur="return checkDate()"></label>
                                        
                                        <c:set var="citySelectPCitys" value="${pCitySet }" scope="request"/>
                                        <c:set var="citySelectCitys" value="${existedCityList }" scope="request"/>
                                        <jsp:include page="/WEB-INF/jsp/common/citySelect.jsp">
                                        	<jsp:param name="id" value="city_code" />
                                        	<jsp:param name="name" value="city_code" />
                                        	<jsp:param name="value" value="${employeeQueryForm.city_code }" />
                                        </jsp:include>
                                        
                                        <label class="checkbox-inline" style="padding-bottom:10px">
                                        	<select class="form-control" name="pay_for">
	                                            <option value="">请选择购买类型</option>
	                                            <option value="1" <c:if test="${employeeQueryForm.pay_for eq 1 }">selected="selected"</c:if>>社保</option>
	                                            <option value="2" <c:if test="${employeeQueryForm.pay_for eq 2 }">selected="selected"</c:if>>公积金</option>
	                                        </select>
                                       </label>
                                        <label class="checkbox-inline" style="padding-bottom:10px">
	                                        <select class="form-control" name="hukou">
	                                            <option value="">请选择户籍类型</option>
	                                            <option value="1" <c:if test="${employeeQueryForm.hukou eq 1 }">selected="selected"</c:if>>本市城镇</option>
	                                            <option value="2" <c:if test="${employeeQueryForm.hukou eq 2 }">selected="selected"</c:if>>本市农村</option>
	                                            <option value="3" <c:if test="${employeeQueryForm.hukou eq 3 }">selected="selected"</c:if>>外地城镇</option>
	                                            <option value="4" <c:if test="${employeeQueryForm.hukou eq 4 }">selected="selected"</c:if>>外地农村</option>
	                                        </select>
                                        </label>
                                        <label class="checkbox-inline" style="padding-bottom:10px">
	                                        <select class="form-control" name="pay_type">
	                                            <option value="">请选择是否新增</option>
	                                            <option value="0" <c:if test="${employeeQueryForm.pay_type eq 0 }">selected="selected"</c:if>>新增</option>
	                                            <option value="2" <c:if test="${employeeQueryForm.pay_type eq 2 }">selected="selected"</c:if>>非新增</option>
	                                        </select>
                                        </label>
                                        
                                        <label class="checkbox-inline" style="padding-bottom:10px">
	                                        <select class="form-control" name="status">
	                                            <option value="">请选择订单状态</option>
	                                            <option value="0" <c:if test="${employeeQueryForm.status eq 0 }">selected="selected"</c:if>>未处理(空白)</option>
	                                            <option value="2" <c:if test="${employeeQueryForm.status eq 2 }">selected="selected"</c:if>>已支付</option>
	                                            <option value="3" <c:if test="${employeeQueryForm.status eq 3 }">selected="selected"</c:if>>申报中</option>
	                                            <option value="4" <c:if test="${employeeQueryForm.status eq 4 }">selected="selected"</c:if>>成功</option>
	                                            <option value="5" <c:if test="${employeeQueryForm.status eq 5 }">selected="selected"</c:if>>不成功</option>
	                                        </select>
                                        </label>
                                        <!-- begin 以下这四个隐藏参数不知道有什么用，待确认是否可以删除 -->
                                        <input type="hidden" name="funds_amount_start" value="${employeeQueryForm.funds_amount_start }" />
                                        <input type="hidden" name="funds_amount_end" value="${employeeQueryForm.funds_amount_end }" />
                                        <input type="hidden" name="shebao_amount_start" value="${employeeQueryForm.shebao_amount_start }" />
                                        <input type="hidden" name="shebao_amount_end" value="${employeeQueryForm.shebao_amount_end }" />
                                        <!-- end -->
                                        <label class="checkbox-inline" style="padding-bottom:10px">
	        			    			    <button type="submit" id="queryBtn" class="btn btn-primary">查 询</button>
	        			    			    <button type="button" id="resetBtn" class="btn btn-primary">重置</button>
                                        </label>
        			    			</div>
        			    		</div>
        			    		</form>
        			    		<!-- 分页 -->
        			    		<jsp:include page="/WEB-INF/jsp/common/page.jsp">
        			    			<jsp:param name="formId" value="queryEmployeeForm"/>
        			    		</jsp:include>
        			    		<hr/>
        			    		<div class="row">
        			    			<div class="col-lg-12">
        			    				<c:if test="${isProUser == false }">
                                        <button id="exportagencydetailBtn" class="btn btn-info btn-sm">批量导出</button>
                                       	<button id="exportagencydetailformatBtn" class="btn btn-info btn-sm">格式化批量导出</button>
	                                    <button id="inc_status_btn" class="btn btn-primary btn-sm" type="button" onclick="javascript:showBatchStauts('inc_order', 'inc_status_btn');">批量修改状态</button>
	        			    			</c:if>
	        			    			<button type="button" id="import_btn" class="btn btn-primary btn-sm" onclick="toImportResult()">导入设置参缴状态</button>
	                                    <!-- 
                                        <button class="btn btn-primary btn-sm" onclick="toggleDiv('#excelForm')">导入系统订单并核对</button><label id="excelName"></label>
                                        <br /><br />
                                        <form id="excelForm" action="${import_uri }" method="post" enctype="multipart/form-data" style="display: none;" class="form-inline form-upload">
                                           <input type="hidden" value="${employeeQueryForm.month }" name="month">
	                                       <input type="file" id="file" name="file" />
	                                       <button type="submit"  class="btn btn-primary btn-sm">确定导入</button>
                                        </form> -->
                                    </div>
                                  </div>
        			    		<!-- 表格列表 -->
        			    		<div class="row">
        			    			<div class="col-lg-12 width-auto">
        			    				<table id="dataContent" class="table table-striped table-bordered table-hover no-footer dataTable table-title" role="grid">
        			    					<thead>
        			    						<tr>
                                                    <th><input type="checkbox" id="incOrder" name="selectAll"/></th>
                                                    <th>购买城市</th>
                                                    <th>社保流水</th>
                                                    <th>姓名</th>
                                                    <th>身份证号码</th>
                                                    <th>需补差额</th>
                                                    <th>新增</th>
                                                    <th>手机号</th>
                                                    <th>性别</th>
                                                    <th>民族</th>
                                                    <th>户籍类型</th>
                                                    <th>购买类型</th>
                                                    <th>公积金金额</th>
                                                    <th>公积金工资基数</th>
                                                    <th>社保费(不含残保金)</th>
                                                    <th>残保金</th>
                                                    <th>服务费</th>
                                                    <th>缴费金额</th>
                                                    <th>补退款</th>
                                                    <th>预收费</th>
                                                    <th>费用所属月份</th>
                                                    <th>订单月份</th>
                                                    <th>补缴增员月份</th>
                                                    <th>状态</th>
                                                    <th>生成时间</th>
                                                    <th>订单号</th>
                                                </tr>
        			    					</thead>
        			    					<tbody>
											<c:choose>
        			    						<c:when test="${empty pageModel.recordList }">
        			    							没有找到相关记录啊
        			    						</c:when>
        			    						<c:otherwise>
        			    						<c:forEach items="${pageModel.recordList }" var="employee">
	        			    					<tr role="row" <c:if test="${employee.status == 4 }">class="success"</c:if><c:if test="${employee.status == 5 }">class="danger"</c:if>>
	        			    							<td><input type="checkbox" id="incOrder_${employee.order_no }" name="inc_order" value="${employee.order_no }"></td>
	                                                    <td>
															<c:forEach var="city" items="${cityList }"><c:if test="${employee.city_code eq city.id }">${city.name }</c:if></c:forEach>
															${employee.param_name }
														</td>
														<td>
															<c:if test="${employee.sb_wage > 1000}">￥${employee.sb_wage } 
																<c:if test="${employee.wage_status == 2 }"><span class="text-warning">已支付</span></c:if>
																<c:if test="${employee.wage_status == 1 }"><span class="text-danger">未付</span></c:if>
		                                                    	<c:if test="${employee.wage_status == 4 }">已返</c:if>
															</c:if></td>
	                                                    <td><a href="${query_uri }?v=1&id_card=${employee.id_card }">${employee.user_name }</a></td>
	                                                    <td>${employee.id_card }</td>
	                                                    <td ${employee.needRepayAmount>0?'style="background-color:#F99"':'' }>
	                                                    <c:if test="${employee.needRepayAmount > 0 }">
		                                                    <a href="${repay_list_uri }?id_card=${employee.id_card }" target="_blank">
		                                                    	￥${employee.needRepayAmount }
		                                                    </a>
		                                                </c:if>
		                                                </td>
	                                                    <td>
	                                                    <c:if test="${employee.pay_type  eq 0 }">是</c:if>
	                                                    </td>
	                                                    <td>${employee.phone }</td>
	                                                    <td>
	                                                    <c:if test="${employee.gender  eq 1 }">男</c:if>
	                                                    <c:if test="${employee.gender  eq 0 }">女</c:if>
	                                                    </td>
	                                                    <td>${employee.nation}</td>
	                                                    <td>
	                                                    <c:if test="${employee.hukou eq 1 }">本市城镇</c:if>
			                                            <c:if test="${employee.hukou eq 2 }">本市农村</c:if>
			                                            <c:if test="${employee.hukou eq 3 }">外地城镇</c:if>
			                                            <c:if test="${employee.hukou eq 4 }">外地农村</c:if>
														</td>
	                                                    <td>
													<c:if test="${employee.pay_for == 1 }">社保
														<c:if test="${employee.new_card == 1}">(新办卡)</c:if>
														<c:if test="${employee.new_card == 2}">(补办卡)</c:if>
													</c:if>
                                                    <c:if test="${employee.pay_for  eq 2 }">公积金</c:if>
														</td>
	                                                    <td>${employee.funds}</td>
	                                                    <td>${employee.fund_salary}</td>
	                                                    <td>
	                                                    <c:if test="${employee.shebaos - employee.disabled gt 0}">${employee.shebaos - employee.disabled}</c:if>
	                                                    </td>
	                                                    <td>
	                                                    <c:if test="${employee.shebaos - employee.disabled gt 0}">${employee.disabled}</c:if>
	                                                    </td>
	                                                    <td>${employee.shebao_charge + employee.fund_charge + employee.card_charge}</td>
	                                                    <td>${employee.total_fee}</td>
	                                                    <td>
															<c:choose>
															<c:when test="${employee.refundType eq 1 }">
																-${employee.total_fee}
															</c:when>
															<c:otherwise>
															${employee.repayAmount - employee.refundAmount }
															</c:otherwise>
															</c:choose>
														</td>
														<td><c:if test="${employee.pre_charge > 0}">￥${employee.pre_charge}</c:if></td>
	                                                    <td><fmt:formatNumber pattern="#" type="number" value="${(employee.for_month - (employee.for_month mod 100))/100 }"/>年${employee.for_month mod 100 }月</td>
	                                                    <td><fmt:formatNumber pattern="#" type="number" value="${(employee.order_month - (employee.order_month mod 100))/100 }"/>年${employee.order_month mod 100 }月</td>
	                                                    <td><fmt:formatNumber pattern="#" type="number" value="${(employee.added_month - (employee.added_month mod 100))/100 }"/>年${employee.added_month mod 100 }月</td>
	                                                    <td>
	                                                    	<c:if test="${employee.status == 2 }">已支付</c:if>
															<c:if test="${employee.status == 3 }">申报中</c:if>
	                                                    	<c:if test="${employee.status == 4 }">成功</c:if>
	                                                    	<c:if test="${employee.status == 5 }"><font color="#F66">不成功</font></c:if>
	                                                    </td>
	                                                    <td>${employee.gen_time }</td>
	                                                     <td>${employee.order_no }</td>
	        			    						</tr>
        			    						</c:forEach>
        			    						</c:otherwise>
        			    						</c:choose>
        			    					</tbody>
        			    				</table>
        			    			</div>
        			    		</div>
        			    		<hr />
                                <jsp:include page="/WEB-INF/jsp/common/page.jsp">
        			    			<jsp:param name="formId" value="queryEmployeeForm"/>
        			    		</jsp:include>
        			    		
			                    <div class="row">
								 	<div class="col-lg-12" id="helpDiv" style="">
								 		<label>增员：</label><br>
								 		<label style="font-weight:normal">
								 		&nbsp;&nbsp;1. 增员的生成是根据下单的月份，判断上一个月份没有购买则生成增员。</label><br>
								 		<label style="font-weight:normal">
								 		&nbsp;&nbsp;2. 增员生成：每天凌晨1点检查上一天支付成功的订单。</label><br>
								 		<label>正常参缴：</label><br>
								 		<label style="font-weight:normal">
								 		&nbsp;&nbsp;1. 正常参缴的生成是根据当前月的购买订单，判断当前月的参保员工里不存在则是正常参缴的。(因为新增用户已是增员)</label><br>
								 		<label style="font-weight:normal">
								 		&nbsp;&nbsp;2. 正常参缴的生成：各城市配置的增员截止日期的第二天凌晨1点。</label><br>
								 		<label>减员：</label><br>
								 		<label style="font-weight:normal">
								 		&nbsp;&nbsp;1. 减员的生成是根据上一个月份的参保员工(含增员)，判断当前月份没继续购买则生成减员。</label><br>
								 		<label style="font-weight:normal">
								 		&nbsp;&nbsp;2. 减员生成：各城市配置的减员截止日期的第二天凌晨2点。</label><br>
								 	</div>
								 </div>
        			    	  </div>
        			    	  <!-- end -->
        			    	</div>
            			</div>
            		</div>
            	</div>
            </div>
        </div>
	</div>
	
	<div id="statusBox" style="display:none;width:300px">
		<form action="" name="statusForm" id="statusForm" method="post">
		<label class="checkbox-inline" style="padding-bottom:10px">
			<input type="radio" name="status" value="3" checked/>审报中</label><br>
		<label class="checkbox-inline" style="padding-bottom:10px;">
			<input type="radio" name="status" value="4"/>参保、缴存成功 (发短信)</label><br>
		<label class="checkbox-inline" style="padding-bottom:10px;color:#F66">
			<input type="radio" name="status" value="5"/>参保、缴存失败 (发短信)</label><br>
		<input type="text" class="form-control" name="any_reason" id="any_reason" placeholder="原因，可为空,20个文字"/>
		<input type="hidden" class="form-control" id="status_orders" name="status_orders">
		<input type="button" id="btn_dostatus" class="btn btn-primary btn-sm" onclick="doBatchStauts()" style="padding-top:10px" value=" 确 定 ">
		</form>
	</div>
	
   <div class="modal" id="uploadFileModal" tabindex="-1" role="dialog" aria-labelledby="uploadFileModalLabel" aria-hidden="true">
       <div class="modal-dialog modal-lg">
           <div class="modal-content">
               <div class="modal-header">
                   <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                   <h4 class="modal-title" id="uploadFileModalLabel">上传五险一金的参缴状态</h4>
               </div>
               <div class="modal-body">
                   <div class="row">
                       <div class="col-lg-12">
	               		<table class="table table-striped table-bordered no-footer dataTable">
	  						<tr>
                                <th>城市</th>
                                <th>姓名</th>
                                <th>身份证号码</th>
                                <th>社保月份(订单)</th>
                                <th>社保操作月份</th>
                                <th>社保补缴月份</th>
                                <th>公积金月份(订单)</th>
                                <th>公积金操作月份</th>
                                <th>公积金补缴月份</th>
                                <th>社保参保状态</th>
                                <th>社保失败原因</th>
                                <th>公积金参保状态</th>
                                <th>公积金失败原因</th>
                            </tr>
		  				</table>
		  			</div>
		  		</div>
                   <div class="row">
                       <div class="col-lg-12">
               			<div class="alert alert-info">
							<ul>
								<li><b>模板见上面</b>。后四列是结果列：</li>
								<li>1. 两状态列；值：成功 / 失败 / <b>留空(不做状态更改)</b>；&nbsp;&nbsp;&nbsp;&nbsp; 2. 两失败原因列；值：成功时可以留空； </li>
								<li>区分记录的条件：城市 + 五险一金类型 + 订单月份 + 身份证号； </li>
							</ul>
						</div>
		  			</div>
		  		</div>
                <div class="row">
                    <div class="col-lg-12">
	                   <form id="uploadForm" class="form-horizontal" role="form">
	                       <div class="form-group fileupload-buttonbar">
	                           <div id="progress" class="col-md-8">
	                               <div id="progress" style="background:#E6E6E6">
	                                   <div class="bar" style="width:0%;"></div>
	                               </div>
	                           </div>
	                           <div class="col-md-2">
								 <span class="btn btn-outline btn-success fileinput-button">
						             <i class="glyphicon glyphicon-plus"></i>
						             <span>请选择导入文件...</span>
						             <input type="file" name="files" id="fileupload" accept=".xls,.xlsx"/>
						         </span>
	                           </div>
	                       </div>
	                   </form>
		  			</div>
		  		</div>
                   <div class="row">
                       <div class="col-lg-12">
                           <div class="col-lg-7">
                               <div class="alert alert-warning" id="wsErrBody" style="height:48%;overflow:auto;color: #c7254e">
                               </div>
                           </div>
						<div class="col-lg-5">
                               <div class="alert alert-info" id="wsBody" style="height:48%;overflow:auto;">
							</div>
						</div>
					</div>
				</div>
               </div>
               <div class="modal-footer">
                   <button class="btn btn-default" data-dismiss="modal">关闭/取消</button>
               </div>
           </div>
           <!-- /.modal-content -->
       </div>
       <!-- /.modal-dialog -->
   </div>
	<!-- 批量导出 -->
	<form action="${export_uri }" id="exportagencydetailForm" class="form-inline inline"></form>
	<!-- 格式化批量导出 -->
	<form action="${export_formate_uri }" id="exportagencydetailformatForm" class="form-inline inline"></form>
</body>

<script src="https://cdn.jsdelivr.net/sockjs/1/sockjs.min.js"></script>
<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
<script src="/as/jquery-upload-file/vendor/jquery.ui.widget.js"></script>
<!-- The basic File Upload plugin -->
<script src="/as/jquery-upload-file/jquery.fileupload.js"></script>
<!--[if (gte IE 8)&(lt IE 10)]>
<script src="/as/jquery-upload-file/cors/jquery.xdr-transport.js"></script>
<![endif]-->
<script lang="text/javascript">
var import_result_uri = "${import_result_uri}";

   $(function(){
	   //重置按钮响应时间
	   $("#resetBtn").click(function(){
		   var month = $("#month").val();
		   $("#queryEmployeeForm").find("input[type=text],select").filter(function(index) {
				return $(this).attr("dataType") != "city_select";
			}).val("");
		   $("#month").val(month);
	   });
	   
	   //批量导出
	   $("#exportagencydetailBtn").click(function(){
			var $prxForm = $("#exportagencydetailForm");
			var json = CollectData($("#queryEmployeeForm"));
			var formHtml = "";
			if(json != null) {
				for(var key in json) {
					formHtml += '<input name="'+key+'" type="hidden" value="'+json[key]+'"/>';
				}
			}
			$prxForm.html(formHtml);
			$prxForm.submit();
	   });
	   
	   //格式化批量导出
	   $("#exportagencydetailformatBtn").click(function(){
			var json = CollectData($("#queryEmployeeForm"));
			var formHtml = "";
			if(json != null) {
				for(var key in json) {
					formHtml += '<input name="'+key+'" type="hidden" value="'+json[key]+'"/>';
				}
			}
			var $prxForm = $("#exportagencydetailformatForm");
			$prxForm.html(formHtml);
			$prxForm.submit();
		});
	   initFileUpload();
   });
   
   //提交导入系统订单并核对表单前校验
   function checkImportEmployeeForm() {
	   var fileName = $("#file").val();
	   if(fileName == null || fileName == "") {
		   showInfo("请选择要提交的文件");
		   return false;
	   }
	   return true;
   }
   
   // 响应批量修改状态按钮
   function showBatchStauts(checkboxName, status_btn) {
	   var orders = "", c=0;
	   $("input[name='"+checkboxName+"']:checked").each(function(){
		   if (orders == "") {
			   orders = $(this).val();
		   } else {
			   orders += "," + $(this).val();
		   }
		   c++;
	   });
	   if (orders == "") {
		   smokeAlert(500, "请先选择多个订单");
		   return;
	   }
	   $("#status_orders").val(orders);

	  var content=document.getElementById("statusBox");
	  dialog({
		  title: '批量修改订单状态 ' + c,
		  content: content,
		  follow: document.getElementById(status_btn),
		  quickClose:true}).show();
   }
   
   function doBatchStauts() {
	   $("#btn_dostatus").attr('disabled', 'true');
	   $("#btn_dostatus").val('处理中...');
	   var data = $("#statusForm").serialize();
	   jQuery.ajax({
		   url: "${batch_status_uri}", data: data, type:'post',
		   success:function(result){
			   if (result.code == 200) {
				   window.location.reload();
			   } else {
				   $("#btn_dostatus").attr('disabled', 'false');
				   smokeAlert(result.code, result.msg);
			   }
		   }
	   });
   }
   
   function enableSelect(order_no){
	  $("#recon_result"+order_no).removeAttr("disabled");
   }

   function updateReconResult(order_no, recon_result){
	  var data = {
			"order_no": order_no,
			"recon_result": recon_result.value,
			"month": ${employeeQueryForm.month }
		  };
		jQuery.ajax({
			url: "${updaterecon_uri}",
			data: data,
			type:'get', 
			async : true, //默认为true 异步   
			success:function(result){
			   //jQuery("#update_result").html(result);
			   alert("状态更新成功！");
			   $("#recon_result"+order_no).attr("disabled","disabled");
			}
		});
	 }
	 
	 function batchRecon(selectName, resultValue) {
		var nid_var = document.getElementsByName(selectName);
		var checkedCount = 0;
		var ids=new Array();
		for(var i = 0; i < nid_var.length; i ++ ) {
			if(nid_var[i].checked) {
				ids.push(nid_var[i].value);
			}
		}
		checkedCount=ids.length;
		if(0==checkedCount) {
			alert("没有所选项！");
			return;
		} else {
			var updateOk= confirm("确定要更新" + checkedCount + "项吗");
			if(updateOk) {
				var data = {
					"eids": ids.join(","),
					"recon_result": resultValue,
					"month": ${employeeQueryForm.month }
				 };
				jQuery.ajax({
					url: "${batch_recon_uri}",
					data: data,
					type:'post', 
					async : true, //默认为true 异步   
					success:function(result){
					   //jQuery("#update_result").html(result);
					   alert("状态更新成功！");
					   window.location.reload(true);
					}
				});
			}
			alert("更新操作在后台已执行，请耐心等待或稍候刷新页面看结果！");
		}
	 }

	 function toggleDiv(id) {
		$(id).toggle();
	 }
	 

	 function initFileUpload() {
	     $('#progress .bar').css('width', '0%');
	     $('#fileupload').fileupload({
	         dataType: 'json',
	         url: import_result_uri,
	         add: function (e, data) {
	     		smokeAlert(200, "提交并处理中……");
	         	useWebSocket($("#wsBody"), $("#wsErrBody")); // 兼容打开ws
	             $.each(data.files, function (index, file) {
	                 $("#wsBody").prepend("<p>正在上传 " + file.name + "</p>");
	             });
	             $('#progress .bar').css('width', '0%');
	             $("#wsErrBody").html("");
	             $("#wsBody").html("");
	             data.submit();
	         },
	         progressall: function (e, data) {
	             var progress = parseInt(data.loaded / data.total * 100, 10);
	             $('#progress .bar').css('width', progress + '%');
	         },
	         done: function (e, data) {
	             importResultDone(data.result);
	         }
	     });
	     //文件上传前触发事件
	     $('#fileupload').bind('fileuploadsubmit', function (e, data) {
	         //data.formData = $("#eplan_form").serializeArray();  //如果需要额外添加参数可以在这里添加
	     });
	 }
	 
	 function toImportResult() {
	    $("#wsBody").html("");
	    $("#wsErrBody").html("");
        $('#progress .bar').css('width', '0%');
	    $('#uploadFileModal').modal({
	        backdrop: 'static',
	        keyboard: false
	    });
		useWebSocket($("#wsBody"), $("#wsErrBody"));
	}
	 function importResultDone(result) {
		if (result.code == 200) {
			notice(result.data, 5);
		} else {
			notice(result.msg);
		}
	 }
</script>
</html>
